<template>
    <div class='page-content'>
        <el-form ref="model" :model="model" label-width="80px">
            <el-form-item label="银行名称">
                <el-input v-model="model.name" type="text" placeholder="请输入银行名称" style="width:100%"></el-input>
            </el-form-item>
            <el-form-item label="备注">
                <el-input v-model="model.remark" type="text" placeholder="请输入备注" style="width:100%"></el-input>
            </el-form-item>
            <el-form-item label="状态">
                <el-select v-model="model.status" style="width:100%" placeholder="请选择状态">
                <el-option label="禁用" value="0"></el-option>
                <el-option label="正常" value="1"></el-option>
                </el-select>
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button type="primary" @click="onSubmit">确 定</el-button>
        </span>
    </div>
</template>


<script>
    import {editConfigOther,loadConfigOther} from '@/api/config/configOtherApi';

export default {
    data() {
        return {
            model: {}
        };
    },
    created: function () {
        this.loadDetail();
    },
    methods: {
        loadDetail(){
            loadConfigOther().then(res => {
                this.model = res.data.model;
            })
        },
        handleCurrentChange: function (index) {
            this.current = index;
            getConfigBankList({
                page: index,
                status: this.status,
            }).then(res => {
                this.lists = res.data.lists;
                this.allpage = res.data.allpage;
            })
        },
        showDialog: function () {
            this.model = {};
            this.dvEdit = true;
        },
        updateModel: function (row) {
            this.model = row;
            this.dvEdit = true;
        },
        reset: function () {
            this.status = '';
        },
        search: function () {
            this.handleCurrentChange(1);
        },
        handleClose: function (done) {
            this.$confirm("确认关闭？")
                .then(_ => {
                    done();
                })
                    .catch(_ => {
                });
        },
        changeColumn(columns) {
            this.columns = columns;
            this.$refs.table.doLayout()
        },
        onSubmit: function () {
            editConfigBank({
                id: this.model.id,
                remark: this.model.remark,
                status: this.model.status,
                name: this.model.name,
            }).then(res => {
                if (res.code === 1) {
                    this.$message({
                        message: '操作成功',
                        type: 'success'
                    });
                    this.dvEdit = false;
                    this.handleCurrentChange(this.current);
                }
            })
        },
       deleteModel: function (row) {
            this.$confirm("您确认要删除该条数据?", "提示", {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'info'
            }).then(() => {
                deleteConfigBank({
                    id: row.id,
                }).then(res => {
                    if (res.code === 1) {
                        this.$message({
                            message: '操作成功',
                            type: 'success'
                        });
                        this.handleCurrentChange(this.current);
                    }
                })
            }).catch(() => {
            })
        },
    },
}
</script>

<style lang='scss' scoped>
.page-content {
    width: 100%;
    height: 100%;
    .avatar {
        width: 50px;
        height: 50px;
        border-radius: 50%;
    }
}

</style>

